import {CrownFilled} from "@ant-design/icons"
import Admin from "../page/Admin";
import AccessEnum from "./AccessEnum.ts";
import { useSelector } from "react-redux";
import { RootState } from "../store";
import Home from "../page/Home";
import BookCommunity from "../page/BookCommunity";
import BookActivities from "../page/BookActivities";
import ReadingRoom from "../page/ReadingRoom";
import Library from "../page/Library";

interface MenuItem {
  path: string;
  name: string;
  icon?: React.ReactNode;
  component: React.ComponentType;
  access?: AccessEnum;
}

export const MenuHeaderRouter = () => {
  const loginUser = useSelector((state: RootState) => state.loginUser);
  
  const menuItems: MenuItem[] = [
    {
      path: '/home',
      name: '首页',
      icon: <CrownFilled></CrownFilled>,
      component: Home,
    },
    {
      path: '/book-community',
      name: '图书社区',
      component: BookCommunity,
    },
    {
      path: '/reading-room',
      name: '阅览室',
      component: ReadingRoom,
    },
    {
      path: '/library',
      name: '图书馆',
      component: Library,
    },

  ];

  // 只有管理员才能看到管理员菜单
  if (loginUser.userRole === AccessEnum.ADMIN) {
    menuItems.push({
      path: '/admin',
      name: 'admin',
      icon: <CrownFilled></CrownFilled>,
      component: Admin,
      access: AccessEnum.ADMIN
    });
  }

  return menuItems;
}